import { defineStore } from 'pinia'

const useReceiptStore = defineStore('receipt', {
    // 状态
    state () {
        return {
            maintainObj: null as any,
            refreshHcList: false
        }
    },
    getters: {
    },
    actions: {
        setMaintainObj (obj:any) {
            this.maintainObj = obj
        },
        setHc (obj:any) {
            if (this.maintainObj) {
                this.maintainObj.usedRecords.push(obj)
            }
        },
        setRefreshHcList (value: boolean) {
            this.refreshHcList = value
        },
        setResource (value: any) {
            if (this.maintainObj) {
                if (this.maintainObj.id) {
                    this.maintainObj.maintainResources = value.optSectId
                    this.maintainObj.maintainResourcesName = value.optSectName
                } else {
                    this.maintainObj.resource = value.optSectName
                    this.maintainObj.resourceType = value.optSectId
                }
                
            }
        }
    }
})

export default useReceiptStore